# Description: HP DeskJet, OfficeJet, Photosmart, Business Inkjet ve bazı LaserJet serileri için sürücüler
# URL: http://hplipopensource.com/hplip-web/index.html
# Packager: alihan-ozturk28@hotmail.com
# Depends on: v4l-utils libgphoto2 python3-sip python3-qt5 avahi python3 wget ghostscript foomatic-db foomatic-db-engine usbutils sane xsane cups cups-filters rpcbind libusb libusb-compat net-snmp dbus-python python3-gobject python-notify python3-pillow python3-reportlab

name=hplip
version=3.16.10
release=1
source=(http://downloads.sourceforge.net/$name/$name-$version.tar.gz
        0022-Add-include-cups-ppd.h-in-various-places-as-CUPS-2.2.patch
        fix_tabs.patch)


build() {
        cd $name-$version
        patch -Np0 -i $SRC/fix_tabs.patch
        patch -Np1 -i $SRC/0022-Add-include-cups-ppd.h-in-various-places-as-CUPS-2.2.patch

        # Use system foomatic-rip for hpijs driver instead of foomatic-rip-hplip
        # The hpcups driver does not use foomatic-rip
        local i
        for i in ppd/hpijs/*.ppd.gz ; do
                rm -f ${i}.temp
                gunzip -c ${i} | sed 's/foomatic-rip-hplip/foomatic-rip/g' | \
                        gzip > ${i}.temp || return 1
                mv ${i}.temp ${i}
        done

        export AUTOMAKE='automake --foreign'
        autoreconf --force --install

        ./configure --prefix=/usr \
                --enable-qt5 \
                --disable-qt4 \
                --disable-foomatic-rip-hplip-install \
                --enable-foomatic-ppd-install \
                --enable-hpcups-install \
                --enable-new-hpcups \
                --enable-cups-ppd-install \
                --enable-cups-drv-install \
                --enable-hpijs-install \
                --enable-foomatic-drv-install \
                --enable-pp-build \
                --enable-udev-acl-rules \
                --enable-dbus-build  \
                --enable-scan-build \
                --enable-fax-build \
                --enable-network-build
        make
        make -j1 rulesdir=/usr/lib/udev/rules.d DESTDIR=$PKG install

        # hplip ne connait que lfs 6 ...
        mkdir -pv  $PKG/etc
        echo "lfs 6" > $PKG/etc/issue

        # remove config provided by sane and autostart of hp-daemon
        rm -rf $PKG/etc/{sane.d,xdg}

        # remove HAL .fdi file because HAL is no longer used
        rm -vrf $PKG/usr/share/hal

}
